﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>ProcessWaitClose - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The ProcessWaitClose function waits for all matching processes to close." />
<meta name="ahk:equiv-v1" content="commands/Process.htm#WaitClose" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>ProcessWaitClose</h1>

<p>Waits for all matching processes to close.</p>

<pre class="Syntax">PID := <span class="func">ProcessWaitClose</span>(PIDOrName <span class="optional">, Timeout</span>)</pre>

<h2 id="Parameters">参数</h2>
<dl>
    <dt>PIDOrName</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#numbers">整数</a>或<a href="../Concepts.htm#strings">字符串</a></p>
        <p>指定数字(PID) 或进程名:</p>
        <p><strong>PID:</strong> 进程 ID, 唯一标识一个特定进程的数字(只有在此进程的生存期这个数字才有意义). 新运行的进程的 PID 可以通过 <a href="Run.htm">Run</a> 函数获取. 同样的, 窗口的 PID 可以通过 <a href="WinGetPID.htm">WinGetPID</a> 获取. <a href="ProcessExist.htm">ProcessExist</a> 也可以用来获取 PID.</p>
        <p><strong>Name:</strong> 进程的名称, 通常和它的可执行文件名相同(不带路径), 例如 notepad.exe 或 winword.exe. 由于一个名称可能与多个正在运行的进程匹配, 因此将仅对第一个进程进行操作. 名称不区分大小写.</p>
    </dd>
    <dt>Timeout</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#numbers">整数</a>或<a href="../Concepts.htm#numbers">浮点数</a></p>
        <p>If omitted, this function will wait indefinitely. Otherwise, specify the number of seconds (can contain a decimal point) to wait before timing out.</p>
    </dd>
</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
<p>If all matching processes are closed, zero is returned. If this function times out, it returns the <a href="../misc/WinTitle.htm#ahk_pid">Process ID (PID)</a> of the first matching process that still exists.</p>

<h2 id="Remarks">备注</h2>
<p>Processes are checked every 100 milliseconds; the moment the condition is satisfied, the function stops waiting. In other words, rather than waiting for the timeout to expire, it immediately returns and continues execution of the script. 此外, 当函数处于等待状态时, 可以通过<a href="../Hotkeys.htm">热键</a>, <a href="../objects/Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">计时器</a>启动新的<a href="../misc/Threads.htm">线程</a>.</p>

<h2 id="Related">相关</h2>
<p><a href="ProcessWait.htm">ProcessWait</a>, <a href="Run.htm">Run</a>, <a href="WinWaitClose.htm">WinWaitClose</a>, <a href="Process.htm">Process functions</a>, <a href="Win.htm">Win functions</a></p>

<h2 id="Examples">示例</h2>
<p>See <a href="ProcessWait.htm#ExBasic">示例 #1</a> on the <a href="ProcessWait.htm">ProcessWait</a> page.</p>

</body>
</html>